package io.unicorn.modules.water.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.unicorn.common.utils.PageUtils;
import io.unicorn.common.utils.Query;

import io.unicorn.modules.water.dao.VdataerrDao;
import io.unicorn.modules.water.entity.VdataerrEntity;
import io.unicorn.modules.water.service.VdataerrService;


@Service("vdataerrService")
public class VdataerrServiceImpl extends ServiceImpl<VdataerrDao, VdataerrEntity> implements VdataerrService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String deptId = params.get("dept").toString();

        String key   = (String)params.get("key");
        String value = (String)params.get("value");

        IPage<VdataerrEntity> page = this.page(
                new Query<VdataerrEntity>().getPage(params),
                new QueryWrapper<VdataerrEntity>()
                        .like(StringUtils.isNotEmpty(deptId),"dept_id", deptId)
                        .like(StringUtils.isNotBlank(value) && StringUtils.isNotBlank(key), key, value)
        );

        return new PageUtils(page);
    }

}
